<template>
	<u-popup :show="uShow" mode="center"  @close="close"  :round="10" :closeable="true" :closeOnClickOverlay="false">
		<block v-if="isSetPaw">
			<view class="title">设置支付密码</view>
			<u-code-input v-model="oldpaw" :maxlength="6" dot :size="80" :focus="true"></u-code-input>
			<view class="title">再次确认密码</view>
			<u-code-input v-model="newpaw" :maxlength="6" dot :size="80"></u-code-input>
			<u-button type="primary" plain color="#397EF5" @click="sumbit">确认</u-button>
		</block>
		<block v-if="!isSetPaw">
			<view class="title">请输入支付密码</view>
			<u-code-input v-model="paw" :maxlength="6" dot :size="80" :focus="true" @finish="sumbit"></u-code-input>
			<view class="title" style="font-size:30upx;font-weight: bold; 	text-align: center;">初始默认密码000000</view>
		</block>
	</u-popup>
</template>

<script>
	export default{
		data(){
			return {
				oldpaw:'',
				newpaw:'',
				paw:''
			}
		},
		props:{
			uShow:{
				type:Boolean,
				default:false
			},
			isSetPaw:{
				type:Boolean,
				default:false
			},
		},
		onLoad(){},
		methods:{
			close(){
				this.$emit('hide')
				this.oldpaw = ''
				this.newpaw = ''
				this.paw = ''
			},
			//输入密码之后
			sumbit(){
				if(this.isSetPaw){ //设置密码
					if(this.newpaw !== this.oldpaw){
						uni.showToast({
							title: '两次密码不一致，请重新输入！',
							icon: 'none',
						})
					}else{
						this.$emit('investOrder',this.newpaw)
					}
				}else{  //支付密码
					this.$emit('investOrder',this.paw)
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	::v-deep .u-transition{
		justify-content: normal !important;
	}
	::v-deep .u-popup__content{
		width:80%;
		top:30%;
		padding:30upx;
		.massage{
			color: #646668;
			font-size: 28upx;
		}
		.btn-flex{
			flex-direction: row;
			margin-top:40upx;
			.u-button{
				width:45%;
				height:100upx;
			}
		}
		.title{
			margin-bottom:40upx;
			font-size:36upx;
		}
		.u-code-input{
			justify-content: center;
			margin-bottom: 20px;
		}
	}
	::v-deep .u-button--plain{
		margin-right: 14px;
		width:100px;
		float: right;
	}
</style>